package com.music.main;


import java.io.File;

import com.music.R;
import com.music.list.AllMusicActivity;
import com.music.list.MusicListActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

public class MainActivity extends Activity {
	//SD卡路径
	public static String SDPath;
	//布局对象
	LinearLayout back=null;
	//跳转
	Intent intent=null;
	private boolean b=true;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //取消TITLE
	    requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);
        //在SD卡下创建MP3问价夹
        File SDFile=new File(SDPath+"mp3");
        if (!SDFile.exists()) {
        	SDFile.mkdir();
        }
        //播放器开场随即背景设置
        back=(LinearLayout)findViewById(R.id.back);
        int i=(int)(Math.random()*4+1);
        if(i==1){
        	back.setBackgroundResource(R.drawable.back1);
        }else if(i==2){
        	back.setBackgroundResource(R.drawable.back2);
        }else if(i==3){
        	back.setBackgroundResource(R.drawable.back3);
        }else if(i==4){
        	back.setBackgroundResource(R.drawable.back4);
        }
    }
    /*
     * 当点击屏幕时，跳转到歌曲列表页面
     * */
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		if(b){
			Intent i=new Intent();
			i.setClass(this, MusicListActivity.class);
			startActivity(i);//结束当前Activity
			b=false;
			finish();
		}
		return super.onTouchEvent(event);
	}
	
	public MainActivity() {
		super();
		//初始化，获取SD卡路径
		SDPath=Environment.getExternalStorageDirectory().getAbsolutePath()+"/";
		// TODO Auto-generated constructor stub
	}
}